import Cookies from 'js-cookie'

// Token相关
const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

// 用户信息相关
const UserKey = 'User-Info'

export function getUserInfo() {
  const userInfo = Cookies.get(UserKey)
  return userInfo ? JSON.parse(userInfo) : null
}

export function setUserInfo(userInfo) {
  return Cookies.set(UserKey, JSON.stringify(userInfo))
}

export function removeUserInfo() {
  return Cookies.remove(UserKey)
}

// 通用方法
export function setCookie(key, value, expires = 7) {
  return Cookies.set(key, value, { expires: expires })
}

export function getCookie(key) {
  return Cookies.get(key)
}

export function removeCookie(key) {
  return Cookies.remove(key)
} 